package day_2022_12_to_3.day;

/**
 * @author haomin
 * @date 2022/12/28 10:42
 **/
public class Day12_28_Num1750 {
    class Solution {
        public int minimumLength(String s) {
            int l = 0, r = s.length() - 1;
            while(l < r && s.charAt(l) == s.charAt(r)) {
                while(l < r-1 && s.charAt(l) == s.charAt(l+1)) l++;
                while(l+1 < r && s.charAt(r) == s.charAt(r-1)) r--;
                l++; r--;
            }
            return r - l + 1;
        }
    }
}